package com.example.teaching_server.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 活动基地实体类
 * 管理活动举办的基地信息
 */
@Getter
@Setter
@ToString(exclude = {"activities"})
@EqualsAndHashCode(of = "id")
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "activity_bases", indexes = {
        @Index(name = "idx_base_status", columnList = "status"),
        @Index(name = "idx_base_name", columnList = "name")
})
public class ActivityBaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false, unique = true, length = 100)
    @NotBlank(message = "基地名称不能为空")
    private String name;

    @Column(length = 500)
    private String description;

    @Column(nullable = false, length = 200)
    @NotBlank(message = "基地地址不能为空")
    private String address;

    @Column(name = "contact_phone", length = 20)
    private String contactPhone;

    @Column(name = "contact_person", length = 50)
    private String contactPerson;

    @CreationTimestamp
    @Column(name = "created_at", updatable = false)
    private LocalDateTime createdAt;

    @UpdateTimestamp
    @Column(name = "updated_at")
    private LocalDateTime updatedAt;

    @OneToMany(mappedBy = "base", cascade = CascadeType.ALL)
    private List<ActivityEntity> activities;
}
